
#include "myQt.h"

myQt::myQt()
{
	//实列化两个对象
	btn = new QPushButton;
	label = new QLabel("0");

	//关联信号和槽函数
	connect(btn, SIGNAL(clicked()), this, SLOT(mySlot()));
	connect(this, SIGNAL(mySignal(int)), label, SLOT(setNum(int)));

	//创建一个垂直布局
	QVBoxLayout *hLay = new QVBoxLayout();
	//将btn加入到布局
	hLay->addWidget(btn);
	//将label加入到布局
	hLay->addWidget(label);
	//加载布局
	setLayout(hLay);
}

void myQt::mySlot()
{
	emit mySignal(1000);
}
